/*
 * graph.h -- this file is part of mISPL.
 * Copyright (C) 2011 Christian Krause
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
#ifndef GRAPH_H_
#define GRAPH_H_

#include "common.h"

/*** Maximum number of nodes (not a real limit) ***/
#define MAX_NODES 1024

/*** Graph data type ***/
typedef struct __graph __graph_s;
typedef __graph_s* graph_t;
struct __graph {
	int nodes;
	char edges[MAX_NODES*MAX_NODES];
};

/*** Path data type ***/
typedef struct __path __path_s;
typedef __path_s* path_t;
struct __path {
	int length;
	int nodes[MAX_NODES];
};

graph_t	graph_init(int nodes);
void	graph_clear(graph_t graph);
void	graph_add_edge(graph_t graph, int source, int target);
void	graph_remove_edge(graph_t graph, int source, int target);
path_t	graph_find_path(graph_t graph, int start, int end);
bool_t	graph_exists_path(graph_t graph, int start, int end);

path_t	path_init(int maxlength);
void	path_print(path_t pat);
void	path_clear(path_t pat);

#endif /* GRAPH_H_ */
